<template>
  <div class="warp">
    <div style="padding: 20px 0 10px">
        <span
          style="
            width: 8px;
            height: 24px;
            background: #2e6cd1;
            display: inline-block;
            margin-right: 12px;
            vertical-align: top;
          "
        ></span>
      <span style="font-size: 22px;">科室一览</span>
    </div>
    <div class="text-box">
      <div class="text item">
        <div class="nav">
            <span class="nav_fonter">
              <img src="../../icons/img/xianyou.png" class="img" alt />
              现有患者数：
              <span class="new_font" style="color: #2d8cf0">{{ list }}</span
              >&nbsp;人
            </span>
        </div>
        <div class="nav">
            <span class="nav_fonter">
              <img src="../../icons/img/zhuanru.png" class="img" alt />
              今日入科患者数：
              <span class="new_font" style="color: #ff9900">{{ today }}</span
              >&nbsp;人
            </span>
        </div>
        <div class="nav">
            <span class="nav_fonter">
              <img src="../../icons/img/today.png" class="img" alt />
              今日出科患者数：
              <span class="new_font" style="color: #19be6b">{{
                  todayExitNum
                }}</span
              >&nbsp;人
            </span>
        </div>
      </div>
      <div class="text item">
        <p class="name">在科病人来源</p>
        <div id="main"></div>
      </div>
      <div class="text item">
        <p class="name">本月转入和转出</p>
        <div id="mmouth"></div>
      </div>
      <div style="clear: both"></div>
    </div>

    <div style="padding: 20px 0 10px">
        <span
          style="
            width: 8px;
            height: 24px;
            background: #2e6cd1;
            display: inline-block;
            margin-right: 12px;
            vertical-align: top;
          "
        ></span>
      <span style="font-size: 22px;">床位列表</span>
    </div>
    <bed-card-list></bed-card-list>
  </div>
</template>
<script>
import echarts from "echarts";

import {
  getNowPatientNum,
  getMonthPatient,
  getPatientSource,
} from "@/api/table";
import BedCardList from "@/views/dashboard/bedCardList";

export default {
  components: {
    BedCardList
  },
  data() {
    return {
      charts: "",
      list: "", //现在患者
      today: "", //今日患者
      todayExitNum: "", //转出
      arr: []
    };
  },
  mounted() {
    this.$nextTick(function () {
      this.drawPie("main");
      this.drawmoune("mmouth");
    });

    getNowPatientNum().then((res) => {
      this.list = res.existingNum;
      this.today = res.todayEnterNum;
      this.todayExitNum = res.todayExitNum;
    });
  },
  methods: {
    drawPie(id) {
      //来源
      getPatientSource().then((res) => {
        this.arr = res.data;
        this.charts = echarts.init(document.getElementById(id));
        this.charts.setOption({
          tooltip: {
            trigger: "item",
            formatter: "{a} <br/>{b} : {c} ({d}%)",
          },
          series: [
            {
              name:"",
              type: "pie",
              radius: "70%",
              center: ["50%", "50%"],
              roseType: "area",
              data: this.arr,
            },
          ],
        });
      });
    },
    drawmoune(id) {
      //月
      getMonthPatient().then((res) => {
        this.arr = res.data;
        this.charts = echarts.init(document.getElementById(id));
        this.charts.setOption({
          tooltip: {
            trigger: "item",
            formatter: "{a} <br/>{b} : {c} ({d}%)",
          },
          series: [
            {
              name:"",
              type: "pie",
              radius: "70%",
              center: ["50%", "50%"],
              roseType: "area",
              data: this.arr,
            },
          ],
        });
      });
    }
  }
};
</script>
<style lang="scss" scoped>
.warp {
  width: 100%;
  height: 100%;
  margin: 0 auto;
  padding: 0 10px;
  background: #eff1f5;
}
.text-box{
  display: flex;
  justify-content: space-between;
  .text {
    font-size: 14px;
    width: 32%;
    height: 358px;
    margin: 0 1%;
    background: #ffffff;
  }
}
#main {
  box-sizing: border-box;
  padding-top: 6px;
  margin: 0 auto;
  width: 90%;
  height: 298px;
}
#mmouth {
  box-sizing: border-box;
  padding-top: 6px;
  margin: 0 auto;
  width: 90%;
  height: 298px;
}
.nav {
  width: 90%;
  height: 90px;
  line-height: 90px;
  margin: 20px auto;
  background: #f4fbfd;
}
.nav_fonter {
  line-height: 71px;
  font-size: 18px;
  margin-left: 10px;
}
.new_font {
  font-size: 25px;
}
.name {
  text-align: center;
  background: #e8f0fa;
  width: 128px;
  height: 38px;
  margin: 0 auto;
  line-height: 38px;
  font-size: 18px;
  font-weight: 400;
  color: #5274a0;
}
.img {
  width: 50px;
  height: 50px;
  float: left;
  margin-top: 16px;
  margin-left: 20px;
}
</style>
